package com.heer.gymnasium.module.main.beans;

import com.heer.gymnasium.base.BaseBean;
import com.heer.gymnasium.module.card.beans.CardResponseBean;
import com.heer.gymnasium.module.order.beans.OrderResponseListBean;
import com.heer.gymnasium.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * 出入场
 * Created by zy on 2018/1/22.
 */

public class AdmissionBean extends BaseBean {
    private String card_id;
    private String cardName;
    private String admissionType;
    private String url;
    private String typeName;
    private String address;
    private String endTime;

    public String getCard_id() {
        return card_id;
    }

    public void setCard_id(String card_id) {
        this.card_id = card_id;
    }

    public String getCardName() {
        return cardName;
    }

    public void setCardName(String cardName) {
        this.cardName = cardName;
    }

    public String getAdmissionType() {
        return admissionType;
    }

    public void setAdmissionType(String admissionType) {
        this.admissionType = admissionType;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public static List<AdmissionBean> dataChange(List<CardResponseBean.Item> itemList) {

        List<AdmissionBean> admissionBeanList = new ArrayList<>();
        if (itemList == null) {
            return null;
        }
        for (int i = 0; i < itemList.size(); i++) {
            AdmissionBean bean = new AdmissionBean();
            bean.setTypeName(itemList.get(i).getCat_name());
            bean.setAddress(itemList.get(i).getStadiumname());
            if (itemList.get(i).getCardType().equals("21")) {
                bean.setCardName(itemList.get(i).getCard_name());
                bean.setAdmissionType(itemList.get(i).getCardType());
                bean.setEndTime(StringUtils.getPhpDateFormat(itemList.get(i).getEtime(), new SimpleDateFormat("yyyy/MM/dd")) + "\n到期");
            } else {
                bean.setCardName(itemList.get(i).getShow_name());
                bean.setAdmissionType(itemList.get(i).getCardType());
                String sTime = StringUtils.getPhpDateFormat(itemList.get(i).getStime(), new SimpleDateFormat("yyyy/MM/dd HH:mm"));
                String eTime = StringUtils.getPhpDateFormat(itemList.get(i).getEtime(), new SimpleDateFormat("HH:mm"));
                bean.setEndTime(sTime.split(" ")[0] + "\n"
                        + sTime.split(" ")[1]
                        + "-" + eTime);
            }
            bean.setCard_id(itemList.get(i).getCard_id());
            bean.setUrl(itemList.get(i).getStadiumpic());
            admissionBeanList.add(bean);

        }
        return admissionBeanList;
    }
}
